package com.risen.project.enums;

import lombok.Getter;

import java.util.Arrays;
import java.util.Optional;

/**
 * 同步状态枚举
 */
@Getter
public enum SyncStatusEnum {
    NOT_SYNC(0, "未上报"),
    SYNC_SUCCESS(1, "已上报"),
    SYNC_FAIL(2, "上报失败"),
    ;

    private final Integer code;
    private final String msg;

    SyncStatusEnum(Integer code, String msg) {
        this.code = code;
        this.msg = msg;
    }

    public static String getMsgByCode(Integer code) {
        Optional<SyncStatusEnum> optional = Arrays.stream(values())
                .filter(c -> c.code.equals(code))
                .findFirst();

        return optional.isPresent() ? optional.get().msg : "";
    }
}
